import { getHomeOrderStatusQty } from '@/api/home'
import { ref } from 'vue'

export default () => {
  // 获取工单状态统计数量
  const getOrderStatusQtyLoading = ref(false)

  // 工单状态统计数量
  const orderStatusQty = ref<HomeOrderStatusQty>({
    cancelOrderQty: 0,
    endOrderQty: 0,
    processingOrderQty: 0,
    totalOrderQty: 0,
    waitDisaptchOrderQty: 0,
    waitProcessingOrderQty: 0,
  })

  /**
   * 获取工单状态统计数量
   */
  const getOrderStatusQty = async () => {
    getOrderStatusQtyLoading.value = true
    const res = await getHomeOrderStatusQty()
    orderStatusQty.value = res.data.data.row
    getOrderStatusQtyLoading.value = false
  }

  return {
    orderStatusQty,
    getOrderStatusQtyLoading,
    getOrderStatusQty,
  }
}
